﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
//using Newtonsoft.Json;

namespace TienTeTuong
{
    public partial class AjaxLoadCateDetailOption : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string optionID = Request.QueryString["optid"];
            ProductDetailBUS proBUS = new ProductDetailBUS();
            List<CateDetailProductDTO> lstProDetail = new List<CateDetailProductDTO>();
            lstProDetail = proBUS.GetListProductDetail(optionID);
            int Price=0;
            string strRes = "<ul id=\"ulProName\">";
            foreach (var Re in lstProDetail)
            {
                strRes += "<li>" +Re.ProName +"</li>";
                Price += int.Parse(Re.Price);
            }

            strRes += "</ul>";

             strRes+= "<div class=\"productPrice\"><span>"+ Price+"</span> VNĐ</div>";

            Response.Write(strRes);

            //using Json .NET
            //  string jResult = JsonConvert.SerializeObject(lstProDetail);
            //  Response.Write(jResult);
            ////respone Data using json
            //string json = "{\"data\":[";
            //foreach (var v in lstProDetail)
            //{
            //    json += "{\"name\":\"" + v.ProName + "\",\"price\":\"" + v.Price + "\"},";
            //}
            //json += "]}";
            //// int sLength = json.Length;
            ////   json.sp
            ////   json.Remove(json.LastIndexOf(','));


            //json = json.Replace("\\", "").Replace(",]}", "]}");
            //Response.Write(json);

        }
    }
}